var app = getApp();
Page({
  data: {
    zhanghao:'',
    password:''
  },

  onLoad: function (options) {

  },

  onShow: function () {

  },
  zongsy: function (e) {
    wx.navigateTo({
      url: 'zongsy'
    });
  },
  zhanghao:function (e) {
    var zhanghao = e.detail.value;
    console.log(zhanghao)
    this.setData({
      zhanghao:zhanghao
    })
  },
  mima:function (e) {
    var password = e.detail.value;
    console.log(password)
    this.setData({
      password:password
    })
  },
  login:function(){
    var t = this;
    var name = t.data.zhanghao;
    var password = t.data.password;
    if(!name){
      app.showToast("请输入账号")
    }else if(!password){
      app.showToast("请输入密码")
    }else{
      app.visit("account/login", {
        name:name,
        password:password
      }, "", function(c) {
        console.log(c)
        if(0 == c.code){
          wx.setStorageSync("store_id",c.data.store_id);
          wx.setStorageSync("account_id",c.data.id);
          wx.navigateTo({
            url: 'index?qubie=1'
          });
        }else{
          app.showToast(c.msg)
        }
      })
    }
  }

})